﻿
using System;
using System.Collections.Generic;
using Family.Core.Model;
using Family.Tests.Extensions;

namespace Family.Tests.Infrastructure
{
    public class NHMemoryData
    {
        private int memoryID = 100;

        #region Mappings entities

        public Category Category { get; set; }
        public Product Product { get; set; }
        public OrderItem OrderItem { get; set; }
        public Order Order { get; set; }

        #endregion

        protected List<Category> Categories { get; set; }
        protected List<Product> Products { get; set; }
        protected List<Order> Orders { get; set; }
        protected List<OrderItem> OrderItems { get; set; }

        public NHMemoryData()
        {
            // buisness
            Category = new Category { Name = "memory category" }.SetIdTo(1);
            Order = new Order { Date = DateTime.Now.TruncateToSeconds() }.SetIdTo(1);
            Product = new Product(Category) { Name = "memory product" }.SetIdTo(1);
            OrderItem = new OrderItem(Order, Product) { Amount = 123 }.SetIdTo(1);

            Categories = new List<Category>();
            Products = new List<Product>();
            Orders = new List<Order>();
            OrderItems = new List<OrderItem>();

            InitTestData();
        }

        private void InitTestData()
        {
            Categories.Add(new Category { Name = "category.1" }); //.SetIdTo(memoryID + 1));
            Categories.Add(new Category { Name = "category.2" }); // .SetIdTo(memoryID + 2));

            Products.Add(new Product(Categories[0]) { Name = "product.1.1" }); //.SetIdTo(memoryID + 1));
            Products.Add(new Product(Categories[0]) { Name = "product.2.1" }); //.SetIdTo(memoryID + 2));
            Products.Add(new Product(Categories[1]) { Name = "product.3.2" }); //.SetIdTo(memoryID + 3));

            Orders.Add(new Order {Date = DateTime.Now.TruncateToSeconds()}); //.SetIdTo(1));

            OrderItems.Add(new OrderItem(Orders[0], Products[1]) {Amount = 123}); //.SetIdTo(1));
        }
    }
}
